<?php

namespace app\common\service;

use GatewayClient\Gateway;
use think\facade\Config;

/**
 * GatewayClient
 * Class GatewayClientServer
 * @package app\im\service
 * @link https://github.com/walkor/GatewayClient
 * @method sendToAll($data)
 * @method sendToClient($client_id, $data)
 * @method closeClient($client_id)
 * @method isOnline($client_id)
 * @method bindUid($client_id, $uid)
 * @method isUidOnline($uid)
 * @method getClientIdByUid($uid)
 * @method unbindUid($client_id, $uid)
 * @method sendToUid($uid, $dat)
 * @method joinGroup($client_id, $group)
 * @method sendToGroup($group, $data)
 * @method leaveGroup($client_id, $group)
 * @method getClientCountByGroup($group)
 * @method getClientSessionsByGroup($group)
 * @method getAllClientCount()
 * @method getAllClientSessions()
 * @method setSession($client_id, $session)
 * @method updateSession($client_id, $session)
 * @method getSession($client_id)
 */
class GatewayClientServer
{
    public function __construct()
    {
        // 初始化
        Gateway::$registerAddress = Config::get('gatewayclient.registerAddress', '127.0.0.1:1238');
    }

    public function __call($name, $args)
    {
        try {

            return Gateway::$name(...$args);
        } catch (\Exception $exception) {
            // 不报错
        }
    }
}
